#ifndef AREAUI_H
#define AREAUI_H

#include "languageframe.h"
#include "addlanguagedialog.h"
#include "addinputmethoddialog.h"
#include "libukcc/widgets/Label/titlelabel.h"
#include "addbutton.h"
#include "settinggroup.h"
#include "comboxwidget.h"
#include <QWidget>
#include <QVBoxLayout>

class AreaUi : public QWidget
{
    Q_OBJECT

public:
    enum ComboBoxOrder {
        COUNTRY = 0,
        CALENDAR,
        FIRSTDAY,
        DATEFORMAT,
        TIMEFORMAT
    };
    AreaUi(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
    virtual ~AreaUi();
    void initUi();
    void initLanguageFormat();
    void initSystemLanguage();
    void settingForIntel();

public:
    inline QComboBox *countryComboBox()
    {
        if (countryWidget) {
            return countryWidget->comboBox();
        } else {
            return nullptr;
        }
    }

    inline QComboBox *calendarComboBox()
    {
        if (calendarWidget) {
            return calendarWidget->comboBox();
        } else {
            return nullptr;
        }
    }

    inline QComboBox *firstDayComboBox()
    {
        if (dayWidget) {
            return dayWidget->comboBox();
        } else {
            return nullptr;
        }
    }

    inline QComboBox *dateComboBox()
    {
        if (dateWidget) {
            return dateWidget->comboBox();
        } else {
            return nullptr;
        }
    }

    inline QComboBox *timeComboBox()
    {
        if (timeWidget) {
            return timeWidget->comboBox();
        } else {
            return nullptr;
        }
    }

    inline AddButton *addbutton()
    {
        return addLanguageBtn;
    }

    inline AddLanguageDialog *languageDialog()
    {
        return addLanguageDialog;
    }

    inline AddInputMethodDialog *inputMethodDialog()
    {
        return addInputMehtodDialog;
    }

    void addShowLanguage(QString languageCode, QString languageName, bool selected = false);
    void clearShowLanguage();
    void reloadLanguageFrameIcon();

Q_SIGNALS:
    void languageChanged(QString languageCode);
    void showLanguageListRemoved(QString languageCode);

private:
    QVBoxLayout *uiLayout       = nullptr;
    QVBoxLayout *formatLayout   = nullptr;
    QVBoxLayout *LanguageLayout = nullptr;

private:
    TitleLabel   *formatTitleLabel = nullptr;
    SettingGroup *formatGroup      = nullptr;
    ComboxWidget *countryWidget    = nullptr;
    ComboxWidget *calendarWidget   = nullptr;
    ComboxWidget *dayWidget        = nullptr;
    ComboxWidget *dateWidget       = nullptr;
    ComboxWidget *timeWidget       = nullptr;

private:
    TitleLabel           *languageTitleLable   = nullptr;
    AddButton            *addLanguageBtn       = nullptr;
    SettingGroup         *languageGroup        = nullptr;
    AddLanguageDialog    *addLanguageDialog    = nullptr;
    AddInputMethodDialog *addInputMehtodDialog = nullptr;

private:
    QList<LanguageFrame*> languageFrameList = {};
};

#endif // AREAUI_H
